package com.sghy.xcxservice.controller;

import com.alibaba.fastjson.JSONObject;
import com.sghy.xcxservice.service.*;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public abstract class BaseController {
    
    
    
    public static Map<String, Object> SUS() {
        Map<String, Object> map = new HashMap<>();
        map.put("code", 200);
        map.put("data", "");
        return map;
    }
    
    /**
     * 正常返回只有data
     * @param data
     * @return
     */
    public static Map<String, Object> SUS(Object data) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", 200);
        map.put("data", data);
        return map;
    }
    
    /**
     * 表单返回
     * @param data
     * @return
     */
    public static Map<String, Object> TABLE(Object data, long total) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", 200);
        map.put("data", data);
        map.put("total", total);
        return map;
    }
    /**
     * 表单返回
     * @param data
     * @return Map
     */
    public static Map<String, Object> TABLE(Object data) {
        JSONObject items = new JSONObject();
        items.put("items", data);
        if (data instanceof List) {
            items.put("total", ((List<?>) data).size());
        }
        Map<String, Object> map = new HashMap<>();
        map.put("code", 200);
        map.put("data", items);
        if (data instanceof List) {
            map.put("total", ((List<?>) data).size());
        }
        return map;
    }

    
    @Autowired
    protected BgbLoginService loginService;
    
    @Autowired
    protected BgbOrgUserService orgUserService;
    
    @Autowired
    protected BgbRoomService roomService;
    
    @Autowired
    protected BgbClockInService clockInService;
    
    
    @Autowired
    protected BgbRoomContentService roomContentService;
    

}
